define(function () {
    'use strict';

    function ctrl($scope,CommonService, LocalCacheService, WebService) {
        function init() {
            $scope.user = LocalCacheService.getUser();
            //创业板转签条件检查
            var params = {client_id:$scope.user.client_id};
            WebService.checkStockSecond(params).then(function (data) {
                if(data.error_no != '0'){
                    if(data.error_no=='-998'){
                        $scope.entrep.state =2;
                        $scope.entrep.alert = '您尚未在天风证券开立深A股东账户！';
                    }else if(data.error_no=='-8'){
                        $scope.entrep.state =4;
                        $scope.entrep.alert = '您好，创业板转签请在交易日09:00-16:00进行办理。';
                    }else if(data.error_no=='-9'&&data.error_info=='您未签约创业板，不具备创业板登记条件'){
                        $scope.entrep.state =3;
                        $scope.entrep.alert = '您尚未开通过创业板！根据证监会要求，首次开通创业板需到营业部办理！';
                    }else{
                        $scope.entrep.state =4;
                        $scope.entrep.alert = data.error_info;
                    }
                }else{
                    $scope.entrep.state = 1;
                    $scope.entrep.alert = '您已满足所有条件！';
                }
            },function(){
                CommonService.showAlert({message:'检测失败'})
            });
            //根据转签状态来改变下面属性
            $scope.entrep = {state: 0, alert: '正在检测转签条件...'};
        }

        $scope.$on('$ionicView.beforeEnter', function () {
            init();
        });
    }

    ctrl.$inject = ['$scope','CommonService', 'LocalCacheService', 'WebService'];
    return ctrl;
});
